<template>
  <div>
    <el-menu :default-active="activeIndex"
             class="el-menu-demo"
             mode="horizontal"
             active-text-color="blue"
             text-color="black">
      <el-menu-item index="1">姓名</el-menu-item>
      <el-menu-item index="2">职位</el-menu-item>
      <el-menu-item index="3"
                    @click="dialogFormVisible = true">修改密码
      </el-menu-item>
      <el-menu-item @click="clickOut">退出系统</el-menu-item>
    </el-menu>
    <el-dialog @close="close"
               :visible.sync="dialogFormVisible">
      <el-form :model="ruleForm"
               status-icon
               :rules="rules"
               ref="ruleForm"
               label-width="100px"
               class="demo-ruleForm">
        <el-form-item label="原密码" prop="oldPass">
          <el-input type="password" v-model="ruleForm.oldPass" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="新密码" prop="newPass">
          <el-input type="password" v-model="ruleForm.newPass" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submit">提交</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>

</template>

<script>
import {xx} from "../../uilts";
import {changePass} from "../../api/user";

export default {
  name: "headerr",
  data() {
    return {
      activeIndex: '1',
      dialogFormVisible: false,
      ruleForm: {
        oldPass: '',
        newPass: '',
      },
      rules: {
        oldPass: xx(),
        newPass: xx(),
      }
    };
  },
  methods: {
    clickOut() {
      this.$store.dispatch('logout').then(() => {
        this.$router.push('/')
      })
    },
    submit() {
      this.$refs.ruleForm.validate(pass => {

      })
      this.dialogFormVisible = false
    },
    close() {
      this.form = this.ruleForm.password
      this.$refs.ruleForm.resetFields()
    },
  }
}
</script>

<style scoped>

</style>